/*************************************************
Author: Aven 
Date: 1/23/2013
Description:
Notes: 
*************************************************/

#ifndef __CDailyTaskConfig_h__
#define __CDailyTaskConfig_h__

#include "CTArray.h"
#include "CDailyTaskDef.h"

/*暂时放在这里，在合代码的时候一起分开存放 ------------The start*/

/*
//日常任务相关 aven
    ERROR_DTASK_TASK_ID              =  1600,   //错误的任务ID
    ERROR_TBOX_ADD_EMPTY_CONFIG          = 1601, //空宝箱奖励配置
    ERROR_TBOX_ID                        = 1602, //错误的宝箱id
    ERROR_TBOX_DUPLICATED_CONFIG         = 1603, //重复的宝箱id
    ERROR_CLASS_AWARD_ADD_EMPTY_CONFIG   = 1604, //空类型集合配置
    ERROR_CLASS_AWARD_ID                 = 1605, //错误的类型id
    ERROR_CLASS_AWARD_DUPLICATED_CONFIG  = 1606, //重复的类型id
    ERROR_INVALID_VIP                    = 1607, //非法vip用户
    ERROR_DTASK_EXCEED_CEIL              = 1608, //已经达到上限值，不能再完成获取活跃度
    ERROR_TBOX_CANOT_OPEN                = 1609, //宝箱不可开启
    ERROR_TBOX_OPENED                    = 1610, //宝箱已经开启
    ERROR_DAILY_TASK_CANOT_FIND          = 1611, //当前任务不能找回
    ERROR_DTASK_COMMIT_NOT_FINISHED      =  1612,    //任务没有完成，不能提交
    ERROR_DTASK_COMMIT_NO_TASK           =  1613,    //任务不存在，不能提交
    ERROR_DTASK_ADD_EMPTY_CONFIG         =  1614,     //不能添加空任务配置
    ERROR_DTASK_DUPLICATED_CONFIG        =  1616, //重复的任务配置
    ERROR_DTASK_COMMIT_NPC               =  1618, //提交任务时NPC错误
    ERROR_DTASK_TIME                     =  1619, //错误的任务时间
    ERROR_NOT_FINISH_CUR_DAILYTASK       = 1620, //还没有完成当天任务，不可找回
*/
/*
//日常任务配置
    DAILY_TASK_CLASSTYPE_NONE           = 0, //空类型
    DAILY_TASK_CLASSTYPE_PRESTIGE       = 1, //声望类型
    DAILY_TASK_CLASSTYPE_LEVEL          = 2, //升级类型
    DAILY_TASK_CLASSTYPE_MONEY          = 3, //赚钱类型
    DAILY_TASK_CLASSTYPE_STRONG         = 4, //变强类型

    DAILY_TASK_ID_LOGIN     = 0,   //登陆
    DAILY_TASK_ID_          = 1, //幸运水晶球
    DAILY_TASK_ID_SHOP      = 2,//刷新商店
    DAILY_TASK_ID_GOLD      = 3,//点金石
    DAILY_TASK_ID_GARDEN_PLANT  = 4,//花园种植
    DAILY_TASK_ID_GARDEN_WABAO  = 5,//花园挖宝
    DAILY_TASK_ID_HOE       = 6,//购买挖宝锄
    DAILY_TASK_ID_PET       = 7,//宠物培养
    DAILY_TASK_ID_CARD      = 8,//命运卡牌
    DAILY_TASK_ID_ENERGY    = 9,//买体力
    DAILY_TASK_ID_LESSON    = 10,//上课
    DAILY_TASK_ID_LESSON_TASK          = 11,//上课任务
    DAILY_TASK_ID_ARENA     = 12,//竞技场
    DAILY_TASK_ID_SWEEP     = 13,//扫荡博物馆
    DAILY_TASK_ID_FLOWER    = 14,//送花
    DAILY_TASK_ID_CLAN1     = 15,//家族活动1
    DAILY_TASK_ID_CLAN2     = 16,//家族活动2
    DAILY_TASK_ID_BOSS      = 17,//花园刷怪
    DAILY_TASK_ID_DANCE     = 18,//舞会
    DAILY_TASK_ID_WORLD_BOSS1   = 19,//世界BOSS1
    DAILY_TASK_ID_WORLD_BOSS2   = 20,//世界BOSS2
    DAILY_TASK_ID_SIEGE     = 21,//攻城战
    DAILY_TASK_ID_COLLEGE   = 22,//学院战
    DAILY_TASK_ID_OTHER     = 23,//其他活动
                 
    MAX_DAILY_TASK_CONFIG = 40, //日常任务数量
    MAX_DAILY_TASK_CLASS_CONFIG = 5, //任务类型数量
    MAX_TBOX_NUM = 20,              //宝箱数量
    MAX_TBOX_AWARD_NUM = 4,          //单个宝箱的奖励数量 
    CONST_VIP_HIGH_LEVEL0 = 0,      //not vip common user
    CONST_VIP_HIGH_LEVEL1 = 3,      //vip1-3
    CONST_VIP_HIGH_LEVEL2 = 6,      //vip4-6
    CONST_VIP_HIGH_LEVEL3 = 9,      //vip7-9
    CONST_VIP_HIGH_LEVEL4 = 10,      //vip10+

    CONST_TBOX_CANOT_OPEN = 0,      //宝箱不可开启
    CONST_TBOX_CAN_OPEN = 1,      //宝箱可开启
    CONST_TBOX_OPENED = 2,      //宝箱已经开启
*/

/*
//每日任务消息id
    ID_MAIN_GET_DAILY_TASK = ;      //请求每日任务列表
    ID_MAIN_FIND_YESTERDAY_TASK = ;     //找回昨日任务
    ID_MAIN_OPEN_TBOX = ;               //开启宝箱
*/

/*
class CDTaskStatus:public CTCodeObject
{
public:
    int iTaskId; //任务id
    int iCount; //完成次数
};

class CDailyTaskUserClassData:public CTCodeObject
{
public:
    int _iTaskClassTypeId; //任务类型
    bool _bAwarded;      //是否已经给予类型完成奖励

    CTArray<CDTaskStatus, MAX_DAILY_TASK_CONFIG> _aDTClassStatus;//各项任务完成次数记录
};

//存放在base数据里面，需要入库
class CDailyTaskUserData:public CTCodeObject
{
public:
    int _iLiveValuer;            //活跃度
    CTArray<int, MAX_TBOX_NUM> _aOpenedTBox; //记录已经开启的宝箱id, 0:当前不可开启, 1:可开启, 2:已经开启

    CTArray<CDailyTaskUserClassData, MAX_DAILY_TASK_CLASS_CONFIG> _aDailyTaskUserClass;//用户每日任务类型记录

public:
    void Clear()
    {
        this->_aDailyTaskUserClass.Clear();
        this->_aOpenedTBox.Clear();
        this->_iLiveValuer = 0;
    }
};
*/

/*暂时放在这里，在合代码的时候一起分开存放 ------------The end*/

class CDailyTaskConfig;
class CDailyTaskMgr;

class DailyVipDest
{
public:
    int iTaskId;//任务id
    int iVipLevel;//vip级别
    int iDestNum;//目标次数
};

//任务配置项
class CDailyTaskConfigData
{
    //friend class CDailyTaskConfig;
public:

	CDailyTaskConfigData() 
        :_bHasConfig(false)
    {
        _iTaskId = 0;      
        _bHasCeiling = true;  
        _bFindYesterday = false;
        _iTaskBelong = 0;   
        _iFinishDestNum = 0;
        _iFamilyDestNum = 0;
        _aDailyVipDest.Clear();
    }

	virtual ~CDailyTaskConfigData() 
    {
	}

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;       //该config对象是否有有效值

    int  _iTaskId;          //task id
    bool _bHasCeiling;      //活跃度有上限
    bool _bFindYesterday;   //can find yesterday
    int _iTaskBelong;       //任务类型
    int _iFinishDestNum;
    int _iFamilyDestNum;    //家族目标次数

    CTArray<DailyVipDest, MAX_DAILY_VIP_DEST_CONFIG> _aDailyVipDest;//任务的vip目标次数
};

class CDailyTaskClassAwardConfigData
{
public:
    CDailyTaskClassAwardConfigData()
        :_bHasConfig(false)
    {
        _iTaskBelongType = 0;
        _iAwardItemType = 0; 
        _iAwardItemId = 0; 
        _iAwardNumCommon = 0;
        _iAwardNumVip1 = 0;
        _iAwardNumVip4 = 0;
        _iAwardNumVip7 = 0;
        _iAwardNumVip10 = 0;
    }
    
    virtual ~CDailyTaskClassAwardConfigData()
    {
    }

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iTaskBelongType; //任务类型
    int _iAwardItemType; //奖励物品类型
    int _iAwardItemId; //奖励物品标识
    int _iAwardNumCommon;//普通用户奖励数量
    int _iAwardNumVip1;
    int _iAwardNumVip4;
    int _iAwardNumVip7;
    int _iAwardNumVip10;
};

class CDailyTaskTboxAwardConfigData
{
    friend class CDailyTaskConfig;
public:
    CDailyTaskTboxAwardConfigData()
        :_bHasConfig(false)
    {
    }

    virtual ~CDailyTaskTboxAwardConfigData()
    {
    }

    struct TBoxAward
    {
        unsigned int iAwardItemType;
        unsigned int iAwardItemId;
        unsigned int iAwardNum;
    };

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iTboxId;           //宝箱id
    int _ineed_liveness;    //需要活跃度

    CTLib::CTArray<TBoxAward, MAX_TBOX_AWARD_NUM> _aTboxAwards; //当前宝箱奖励, 最多4个数量
};

class CSecretaryPayConfigData
{
    friend class CDailyTaskConfig;
public:
    CSecretaryPayConfigData()
        :_bHasConfig(false)
    {
    }

    virtual ~CSecretaryPayConfigData()
    {
    }

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iStyleId;           //小秘书形象id
    int _iNeedGold;    //购买形象需要金币
    int _iDailyAddLiveness;    //此形象每日增加活跃度
};

class CSecretaryLevelConfigData
{
    friend class CDailyTaskConfig;
public:
    CSecretaryLevelConfigData()
        :_bHasConfig(false)
    {
        _iLevel = 0;
        _iNeedIntimacy = 0;
        _iPrestigeAdd = 0;
        _iSilverAdd = 0;
    }

    virtual ~CSecretaryLevelConfigData()
    {
    }

    void Clear() {_bHasConfig = false;}
    bool HasConfig() const {return _bHasConfig;}

public:
    bool _bHasConfig;

    int _iLevel;           //小秘书等级
    int _iNeedIntimacy;    //升级需要亲密度
    int _iPrestigeAdd;    //声望小秘书时获得声望奖励加成
    int _iSilverAdd;    //银币小秘书时获得银币奖励加成
};

//任务配置
class CDailyTaskConfig
{
friend class CDailyTaskMgr;
public:
	CDailyTaskConfig() 
    {
	}

	virtual ~CDailyTaskConfig() 
    {
	}

    int Init();

    int GetTaskConfig(unsigned int iTaskID, CDailyTaskConfigData& stData);

    int GetClassAwardConfig(unsigned int iTaskBelongType, CDailyTaskClassAwardConfigData& stData);

    int GetTboxAwardConfig(unsigned int iTboxId, CDailyTaskTboxAwardConfigData& stData);

    int AddClassAwardConfig( CDailyTaskClassAwardConfigData & stData );

    int AddTboxAwardConfig( CDailyTaskTboxAwardConfigData & stData);

    int AddTaskConfig(CDailyTaskConfigData& stConfigData);

    int AddSecretaryPayConfig( CSecretaryPayConfigData& stData );

    int GetSecretaryPayConfig(int _iStyleId, CSecretaryPayConfigData& stData);

    int AddSecretaryLevelConfig( CSecretaryLevelConfigData& stData );

    int GetSecretaryLevelConfig(int iLevel, CSecretaryLevelConfigData& stData);

private:
    // MAX_DAILY_TASK_CONFIG = 40, MAX_DAILY_TASK_CLASS_CONFIG = 4, MAX_TBOX_NUM = 20
    CTLib::CTArray<CDailyTaskConfigData, MAX_DAILY_TASK_CONFIG>                           _astDailyTaskConfigs;        //日常任务配置
    CTLib::CTArray<CDailyTaskClassAwardConfigData, MAX_DAILY_TASK_CLASS_CONFIG>           _astDailyTaskClassAwardConfigs;   //任务类型奖励
    CTLib::CTArray<CDailyTaskTboxAwardConfigData, MAX_TBOX_NUM>      _astDailyTaskTboxConfigs;      //宝箱奖励
    CTLib::CTArray<CSecretaryPayConfigData, MAX_SECRETARY_STYLE_NUM+1>      _astSecretaryPayConfigs;      //购买小秘书配置
    CTLib::CTArray<CSecretaryLevelConfigData, MAX_SECRETARY_LEVEL+1>      _astSecretaryLevelConfigs;      //小秘书等级配置
};

#endif // __CDailyTaskConfig_h__

